<?php
$cs = Yii::app()->getClientScript();
$cs->registerCSSFile(Yii::app()->request->baseUrl.'/css/defaultTheme.css');
$cs->registerScriptFile(Yii::app()->request->baseUrl.'/js/jquery.fixedheadertable.min.js');

$eventList = Blyn::app()->getActiveApp()->getEventList();

$control->renderView('booking_list_header',array());
$detailUrl = $control->getLinkUrl(array('name' => 'detail','id' => 'booking_detail'));

if (isset($availableList)) {
    $courts = array();
    foreach ($availableList as $list) {
        if ($list instanceof BTreeList) {
        }
    }
?>


<div id="court-list">
    
    <?php
    //$bookableMessageList = array(); //储存所有预订项中的场地的inputMedia
    $eventList = Blyn::app()->getActiveApp()->getEventList();
        foreach ($eventList as $event) {
        $eventId = $event->getId();
        $vender = $event->getMessageManager()->getMessage('vender');
        $bookableList = $vender->getMessageManager()->getMessageList();
        foreach ($bookableList as $bookable) {  
            $price = $bookable->getMediaManager()->getMedia('price')->getContent();
            $addUrl = $control->getLinkUrl(array('name' => 'booking_add','id' => 'booking_add'),array('eventId' => $eventId,'bookableId' => $bookable->getId()));
            ?>
            <a href="<?php echo $addUrl;?>">
                <div class="item">
        <!--            <div class="img-div">
                        <img src="<?php // echo Yii::app()->request->baseUrl;?>/images/mobile/place1.jpg" style="width:100%; height:130px;"/>
                    </div>-->
                    <div style="padding: 0;">
                        <div class="court-name">预订项名称：<?php echo $bookable->description; ?></div>
                        <span class="court-price">价    格：<?php echo $price; ?>元<br/><?php echo $eventId; ?><br/><?php echo $bookable->getId(); ?></span>
                        <!--<p><?php // echo Yii::t('BWeSport', 'Location Address')?>：重庆奥林匹克中心</p>-->
                        <!--<div style="font-weight: bold; color:#dedede;"><a href="<?php // echo $detailUrl;?>" style="text-decoration: none;"><?php // echo Yii::t('BWeSport', 'Location Detail Content')?></a></div>-->
                    </div>
                </div>
            </a>
<?php 
            }
        }
    ?>
    
</div>

<div id='tableDiv' style="width:100%;">
<table class="fancyTable" id="myTable01">
	<thead>
	<tr>
		<th>T<br/>Courts</th>
		<?php
			$currDate = clone $slotInfo['min'];
			for ($i=1; $i<=$slotInfo['count']; $i++) {
		?>
		<th><?php
				echo '&nbsp;'.$currDate->format('H:i').'&nbsp;';
				$currDate->add(new DateInterval('PT1H'));
			?></th>
		<?php } ?>
	</tr>
	</thead>
	<tbody>
	</tbody>
</table>
</div>
<div class="clear"></div>

</div><!-- form -->


<script type="text/javascript">
$("input[name=radio-choice-h-5][id=radio-choice-h-6a]").attr("checked","checked");
</script>
<?php
} else {
?>
<div>No available time slot!</div>
<?php
}
?>
